package com.mr.security.web.commons.handler;

import com.mr.security.web.commons.config.SecurityPropertiesConfig;
import com.mr.security.web.commons.exception.AuthorizeException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.ModelAndView;

/**
 * Class: ExceptionHandler
 * User (作者):MRui
 * TODO (描述)：异常捕获处理
 * Date 2018.10.04 14:29
 */
@ControllerAdvice
public class ExceptionHandler {

    @Autowired
    private SecurityPropertiesConfig accountConfig;

    //拦截登陆异常
    @org.springframework.web.bind.annotation.ExceptionHandler(value = AuthorizeException.class)
    public ModelAndView handlerAuthorizeException(){
        return new ModelAndView("redirect:"
                //.concat(accountConfig.getWechatOpenAuthorize())
                .concat("/sell/wechat/qrAuthorize")
                .concat("?returnUrl=")
                .concat("项目地址")
                .concat("/sell/seller/login"));
    }
}
